package demo01;
//用二分查找算x的平方根
class Solution {
    public int mySqrt(int x) {
        int left = 0;
        int right = x;
        if(x <= 1) return 0;
        while(left < right){
            int mid = left + (right - left + 1) / 2;
            if(mid * mid <= x) left = mid;
            else right = mid -1;
        }
        return left;

    }
}